package com.uzhie.jt808.jt1078.entity;

import com.uzhie.jt808.JT808MsgBody;
import com.uzhie.jt808.msg.entity.BitConverter;
import com.uzhie.jt808.msg.entity.MyBuffer;

/**
 *
 * 设备视频状态命令
 * Created by lilongfei on 2018/7/25.
 */
public class JT_9105 implements JT808MsgBody {

    //逻辑通道号
    private byte channel;
    //丢包率
    private byte loss;

    public byte getChannel() {
        return channel;
    }

    public void setChannel(byte channel) {
        this.channel = channel;
    }

    public void setChannel(int channel) {
        byte[] channels = BitConverter.GetBytes(channel);
        setChannel(channels[3]);
    }

    public byte getLoss() {
        return loss;
    }

    public void setLoss(byte loss) {
        this.loss = loss;
    }

    public void setLoss(int loss) {
        byte[] losses = BitConverter.GetBytes(loss);
        setLoss(losses[3]);
    }

    @Override
    public byte[] WriteToBytes() {
        MyBuffer buffer = new MyBuffer();
        buffer.put(channel);
        buffer.put(loss);
        return buffer.array();
    }

    @Override
    public void ReadFromBytes(byte[] body) {
        MyBuffer buffer = new MyBuffer(body);
        setChannel(buffer.get());
        setLoss(buffer.get());
    }
}
